var executeContact = function(contactName, contactEmail, contactText){
  $.ajax({
      url: '/ajax/contact?contactName=' + contactName + '&contactEmail=' + contactEmail + '&contactText=' + contactText,
      dataType: 'json'
     }) 
     .done(function(data){
        var n = noty({text: data.message, type: 'info'});
        if(data.status == 1){
          setTimeout(function(){n.close();}, 1000);
        }
     });
};

var executeLogin = function(login, password){
  $.ajax({
      url: '/ajax/login?login=' + login + "&password=" + password,
      dataType: 'json'
     }) 
     .done(function(data){
        var n = noty({text: data.message, type: data.messageType});
        if(data.status === 1){
          setTimeout(function(){n.close();window.location.href = "/pages/accountAdminister";}, 1000);
        }
     });
};

var executeRegisterAccount = function(acc, password, re_password, email, name, surname, adress, telephone, birthday){
  var url = 'account_name=' + acc + '&re_password=' + re_password + '&password=' + password + "&email=" + email + "&name=" + name + 
            '&surname=' + surname + "&adress=" + adress + "&telephone=" + telephone + "&birthday=" + birthday;
  $.ajax({
      url: '/ajax/registerAccount?' + url,
      dataType: 'json'
     }) 
     .done(function(data){
        var n = noty({text: data.message, type: data.messageType});
        if(data.status === 1){
          setTimeout(function(){n.close();window.location.href = "/pages/accountAdminister";}, 2000);
        }
     });
};

var logout = function(){
  $.ajax({
      url: '/ajax/logout',
      dataType: 'json'
     }) 
     .done(function(data){
        var n = noty({text: data.message, type: data.messageType});
        if(data.status === 1){
          setTimeout(function(){n.close();window.location.href = "/";}, 1000);
        }
     });
};

var changePassword = function(pass, old_pass, re_pass){
  $.ajax({
      url: '/ajax/changePassword?password=' + pass + '&old_password=' + old_pass + '&re_password=' + re_pass,
      dataType: 'json'
     }) 
     .done(function(data){
        var n = noty({text: data.message, type: data.messageType});
        if(data.status === 1){
          setTimeout(function(){n.close();window.location.href = "/";}, 1000);
        }
     });
};

var changeEmail = function(email){
  $.ajax({
      url: '/ajax/changeEmail?email=' + email,
      dataType: 'json'
     }) 
     .done(function(data){
        var n = noty({text: data.message, type: data.messageType});
        if(data.status === 1){
          setTimeout(function(){n.close();window.location.href = "/pages/accountAdminister";}, 1000);
        }
     });
};

function AnimateRotate(b, n) {
    var elem = $(".newsletterBox");
    $({deg: b}).delay(100).animate({deg: n}, {
        duration: 1200,
        step: function (now) {
            elem.css({
                transform: "rotate(" + now + "deg)"
            });
        }
    });
};
function AnimateRotateBack(b, n) {
    var elem = $(".newsletterBox");
    $({deg: b}).delay(1000).animate({deg: n}, {
        duration: 1200,
        step: function (now) {
            elem.css({
                transform: "rotate(" + now + "deg)"
            });
        }
    });
};